package Library.items;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import Library.dbcommands.DBConnector;
import Library.dbcommands.IDBCommands;


public class Books implements IBooks{
	private List<SearchedBook> books = new ArrayList<SearchedBook>();
	private IDBCommands dbCon=DBConnector.connector();
	/**
	 * get books from database and add in List books
	 * @author Sansarova
	 */
	private void printBooks(){
		List<SearchedBook> dbBooks = dbCon.getAllBooks();
		System.out.println("--------------------------------------------------");
		for(SearchedBook b: dbBooks) {
			books.add(b);
			System.out.println("Book: "+b.getTitle());
		}
	}
	
	public List getListOfBooks(){
		printBooks();
		return Collections.unmodifiableList(books);
	}
}
